using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Niu
{
    public partial class FormMain : Form
    {
        public FormMain()
        {
            InitializeComponent();
        }

        private void FormMain_Load(object sender, EventArgs e)
        {
            listRefresh();
        }

        private void listRefresh()
        {
            nLogicalDisk[] LocalDisks = nLogicalDisks.GetAll();

            lstDriver.Items.Clear();

            foreach (nLogicalDisk disk in LocalDisks)
            {
                if (disk.DriveType == nLogicalDiskType.NetworkDrive)
                {
                    lstDriver.Items.Add(disk.Name);
                }
            }
        }

        private void btnDisconnect_Click(object sender, EventArgs e)
        {
            MessageBox.Show(nSmbCon.DisconnectMap(lstDriver.SelectedItem.ToString()).ToString());

            listRefresh();
        }

        private void btnConnect_Click(object sender, EventArgs e)
        {
            MessageBox.Show(nSmbCon.ConnectMap(txtRemote.Text, txtLocal.Text, txtUser.Text, txtPass.Text).ToString());

            listRefresh();
        }
    }
}